<?php
require_once "src/apiClient.php";
require_once "src/contrib/apiCalendarService.php";
session_start();
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Gphotograph extends CI_Controller {
function __construct()
    {
        parent::__construct();
    	$this->load->library('session');
		$this->load->helper('url');
    	$this->load->database();
    	$this->load->model("photographmod");
    	
	}
	
/************* list *****************************/
function assignedlist()
{
	if($this->session->userdata("user")==false && $this->session->userdata("id")<=0&& $this->session->userdata("role")!="photo")
			{
					header('Location:index.php?pages/loginadmin');
						
			}else 
			{
				$pgraphid=$this->session->userdata("id");
				$listpgraphassigned=$this->photographmod->getpgraphassigned($pgraphid);
				$listpgraphshowdone=$this->photographmod->getpgraphshowdone($pgraphid);
				$listpgraphpicasa=$this->photographmod->getpgraphpicasa($pgraphid);
				$liststatusshooting=$this->photographmod->getliststatusshooting();
				//$listphotograph=$this->photographmod->getlistphotograph();
				//$listphotoassigned=$this->photographmod->getuserappointassigned();
				$data=array("listpgraphassigned"=>$listpgraphassigned,"listpgraphshowdone"=>$listpgraphshowdone,"listpgraphpicasa"=>$listpgraphpicasa,"liststatusshooting"=>$liststatusshooting);
				$this->load->view("pgraph/listbypgraph",$data);	
						
			}
}

/******* changed status shooting*******/

function actionsatusshooting()
{
		if($this->session->userdata("user")==false && $this->session->userdata("id")<=0&& $this->session->userdata("role")!="photo")
			{
					header('Location:index.php?pages/loginadmin');
						
			}else 
			{
				$idshooting=$this->input->get_post("idshooting");
				$statusshooting_idstatusshooting=$this->input->get_post("statusshooting_idstatusshooting");
				$data=array("statusshooting_idstatusshooting"=>$statusshooting_idstatusshooting);
				$changed=$this->photographmod->updatetemplate("shooting",$data,"idshooting=$idshooting");
				redirect("index.php?gphotograph/assignedlist",'refresh');
			}	

}


/************* end list *****************************/


/*************************** Add ********************/

	function actionassingnephoto()
	{
		if($this->session->userdata("user")==false && $this->session->userdata("id")<=0&& $this->session->userdata("role")!="admin")
			{
					header('Location:index.php?pages/loginadmin');
						
			}else 
			{
				$idappointments=$this->input->get_post("idappointments");
				$role=$this->input->get_post("role");
				$idphotograph=$this->input->get_post("idphotograph");
				$data=array("User_idUser"=>$idphotograph,"statusshooting_idstatusshooting"=>1,"appointments_idappointments"=>$idappointments);
				$idinsert2=$this->Adminmod-> insertetemplate("shooting",$data);	
				redirect("index.php?gadmin/bookinglistadmin",'refresh');
				
			}
	}


	
	function editassingnephoto()
	{
		if($this->session->userdata("user")==false && $this->session->userdata("id")<=0&& $this->session->userdata("role")!="admin")
			{
					header('Location:index.php?pages/loginadmin');
						
			}else 
			{
				$idappointments=$this->input->get_post("idappointments");
				$role=$this->input->get_post("role");
				$idphotograph=$this->input->get_post("idphotograph");
				$idshooting=$this->input->get_post("idshooting");
				$data=array("User_idUser"=>$idphotograph);
				$idinsert2=$this->Adminmod-> updatetemplate("shooting",$data,"idshooting=$idshooting");
				redirect("index.php?gadmin/bookinglistadmin",'refresh');
			
			}
	}
/***************************** end Add ***************/

}//fin class